<template>
  <div>
    <basic-container>
      <div class="app-container">
        <el-form :model="queryParams" :rules="rules" ref="queryForm" size="small" :inline="true">
          <!-- <div>
            <el-form-item :label="title">
              <el-input v-model="queryParams.sn" placeholder="请输入壳体码" style="width: 200px;"></el-input>
              <el-input v-model="queryParams.code" placeholder="请输入总码" style="width: 200px; margin: 0 10px;"></el-input>
              <el-input v-model="queryParams.grade" placeholder="请输入等级" style="width: 200px;"></el-input>
            </el-form-item>
            <el-form-item>
              <el-button :disabled="isDisabled" type="primary" icon="el-icon-edit" size="mini" @click="handleQuery">绑定</el-button>
            </el-form-item>
          </div>
          <div>
            <el-form-item label="壳体总码删除">
              <el-input v-model="menuMessTwo" placeholder="请输入壳体总码" style="width: 200px;"></el-input>
            </el-form-item>
            <el-form-item>
              <el-button :disabled="menudis" type="primary" icon="el-icon-delete" size="mini" @click="handleDelet">删除</el-button>
            </el-form-item>
          </div> -->
          <div>
         
            <el-form-item :label="titleLab">
              <el-input v-model="maxNub" placeholder="请输入时间" style="width: 200px;" @input="validateInput('maxNub')"></el-input>
            </el-form-item>
            <el-form-item :label="titleLabtwo">
              <el-input v-model="maxTwo" placeholder="请输入时间" style="width: 200px;" @input="validateInput('maxTwo')"></el-input>
            </el-form-item>
            <el-form-item :label="titleLabwhere">
              <el-input v-model="maxthere" placeholder="请输入时间" style="width: 200px;" @input="validateInput('maxthere')"></el-input>
            </el-form-item>
            <el-form-item>
              <el-button  type="primary" icon="el-icon-check" size="mini" @click="DefiniteMdification">确定</el-button>
            </el-form-item>
          </div>
        </el-form>
      </div>
    </basic-container>
  </div>
</template>

<script>
import { bindingCode, delCode, grtUsersall, eidMinAMax } from "@/api/view2";

export default {
  data() {
    return {
      loading: false,
      titleLab:'',
      titleLabtwo:'',
      titleLabwhere:'',
      minNub: '',
      maxNub: '',
      maxTwo:'',
      maxthere:'',
      eidMaxnum: '',
      eidMinnum: '',
      title: "壳体总码绑定",
      queryParams: {
        sn: '',
        code: '',
        grade: ''
      },
      menuMessTwo: '',
      rules: {
        sn: [{ required: true, message: "壳体码不能为空", trigger: "blur" }],
        code: [{ required: true, message: "总码不能为空", trigger: "blur" }],
        grade: [{ required: true, message: "等级不能为空", trigger: "blur" }]
      }
    };
  },
  created() {
    this.getMaxAndMIn();
  },
  computed: {
    isDisabled() {
      return !this.queryParams.sn.trim() || !this.queryParams.code.trim() || !this.queryParams.grade.trim();
    },
    menudis() {
      return !this.menuMessTwo.trim();
    },

  },
  methods: {
    handleQuery() {
      bindingCode(this.queryParams).then(res => {
        console.log(res);
        this.$message({
          message: "绑定成功",
          type: "success"
        });
        this.queryParams.sn = '';
        this.queryParams.code = '';
        this.queryParams.grade = '';
      });
    },
    validateInput(field) {
      this[field] = this[field].replace(/[^0-9]/g, '');
    },
    getMaxAndMIn() {
      grtUsersall().then(res => {
        console.log(res);
        this.titleLab = res.data.doc.interval1516
        this.titleLabtwo = res.data.doc.interval1819
        this.titleLabwhere = res.data.doc.interval2022
        this.maxNub = res.data.interval1516;
        this.maxTwo = res.data.interval1818;
        this.maxthere = res.data.interval2022;
  
      });
    },
    DefiniteMdification() {
      let data = {
        interval1516: Number(this.maxNub),
        interval1819:Number(this.maxTwo),
        interval2022:Number(this.maxthere),
      };
      eidMinAMax(data).then(res => {
          console.log(res);
        this.$message({
          message: "修改成功",
          type: "success"
        });
        this.getMaxAndMIn();
      });
    },
    handleDelet() {
      let data = {
        sn: this.menuMessTwo
      };
      delCode(data).then(res => {
        console.log(res);
        this.$message({
          message: "删除成功",
          type: "success"
        });
      });
    }
  }
};
</script>

<style>
/* 添加你的样式 */
</style>